package com.itshare.video.mapper;

import com.itshare.video.pojo.po.Event;
import com.itshare.video.pojo.po.EventExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.session.RowBounds;

public interface EventMapper {
    long countByExample(EventExample example);

    int deleteByExample(EventExample example);

    @Delete({
        "delete from t_event",
        "where event_id = #{eventId,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long eventId);

    @Insert({
        "insert into t_event (REVISION, CREATED_BY, ",
        "CREATED_TIME, UPDATED_BY, ",
        "UPDATED_TIME, event_content, ",
        "event_type, is_look, ",
        "delete_status)",
        "values (#{revision,jdbcType=INTEGER}, #{createdBy,jdbcType=VARCHAR}, ",
        "#{createdTime,jdbcType=TIMESTAMP}, #{updatedBy,jdbcType=VARCHAR}, ",
        "#{updatedTime,jdbcType=TIMESTAMP}, #{eventContent,jdbcType=VARCHAR}, ",
        "#{eventType,jdbcType=INTEGER}, #{isLook,jdbcType=INTEGER}, ",
        "#{deleteStatus,jdbcType=INTEGER})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="eventId", before=false, resultType=Long.class)
    int insert(Event record);

    int insertSelective(Event record);

    List<Event> selectByExampleWithRowbounds(EventExample example, RowBounds rowBounds);

    List<Event> selectByExample(EventExample example);

    @Select({
        "select",
        "event_id, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME, event_content, ",
        "event_type, is_look, delete_status",
        "from t_event",
        "where event_id = #{eventId,jdbcType=BIGINT}"
    })
    @ResultMap("com.itshare.video.mapper.EventMapper.BaseResultMap")
    Event selectByPrimaryKey(Long eventId);

    int updateByExampleSelective(@Param("record") Event record, @Param("example") EventExample example);

    int updateByExample(@Param("record") Event record, @Param("example") EventExample example);

    int updateByPrimaryKeySelective(Event record);

    @Update({
        "update t_event",
        "set REVISION = #{revision,jdbcType=INTEGER},",
          "CREATED_BY = #{createdBy,jdbcType=VARCHAR},",
          "CREATED_TIME = #{createdTime,jdbcType=TIMESTAMP},",
          "UPDATED_BY = #{updatedBy,jdbcType=VARCHAR},",
          "UPDATED_TIME = #{updatedTime,jdbcType=TIMESTAMP},",
          "event_content = #{eventContent,jdbcType=VARCHAR},",
          "event_type = #{eventType,jdbcType=INTEGER},",
          "is_look = #{isLook,jdbcType=INTEGER},",
          "delete_status = #{deleteStatus,jdbcType=INTEGER}",
        "where event_id = #{eventId,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(Event record);
}